<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/xhtml;charset=UTF-8"/>
<title>PROJEKT Z PRZEDMIOTU SYSTEMY KOMPUTEROWE (SYKO) grupa nr. 16: Opis działania funkcji INC</title>
<link href="tabs.css" rel="stylesheet" type="text/css"/>
<link href="search/search.css" rel="stylesheet" type="text/css"/>
<script type="text/javascript" src="search/search.js"></script>
<link href="doxygen.css" rel="stylesheet" type="text/css"/>
</head>
<body onload='searchBox.OnSelectItem(0);'>
<!-- Wygenerowano przez Doxygen 1.7.4 -->
<script type="text/javascript"><!--
var searchBox = new SearchBox("searchBox", "search",false,'Szukaj');
--></script>
<div id="top">
<div id="titlearea">
<table cellspacing="0" cellpadding="0">
 <tbody>
 <tr style="height: 56px;">
  <td style="padding-left: 0.5em;">
   <div id="projectname">PROJEKT Z PRZEDMIOTU SYSTEMY KOMPUTEROWE (SYKO) grupa nr. 16&#160;<span id="projectnumber">0.01</span></div>
  </td>
 </tr>
 </tbody>
</table>
</div>
  <div id="navrow1" class="tabs">
    <ul class="tablist">
      <li><a href="index.html"><span>Strona&#160;główna</span></a></li>
      <li class="current"><a href="pages.html"><span>Dodatkowe&#160;strony</span></a></li>
      <li><a href="modules.html"><span>Moduły</span></a></li>
      <li><a href="files.html"><span>Pliki</span></a></li>
      <li id="searchli">
        <div id="MSearchBox" class="MSearchBoxInactive">
        <span class="left">
          <img id="MSearchSelect" src="search/mag_sel.png"
               onmouseover="return searchBox.OnSearchSelectShow()"
               onmouseout="return searchBox.OnSearchSelectHide()"
               alt=""/>
          <input type="text" id="MSearchField" value="Szukaj" accesskey="S"
               onfocus="searchBox.OnSearchFieldFocus(true)" 
               onblur="searchBox.OnSearchFieldFocus(false)" 
               onkeyup="searchBox.OnSearchFieldChange(event)"/>
          </span><span class="right">
            <a id="MSearchClose" href="javascript:searchBox.CloseResultsWindow()"><img id="MSearchCloseImg" border="0" src="search/close.png" alt=""/></a>
          </span>
        </div>
      </li>
    </ul>
  </div>
</div>
<div class="header">
  <div class="headertitle">
<div class="title">Opis działania funkcji INC </div>  </div>
</div>
<div class="contents">
<div class="textblock"><h2><a class="anchor" id="sec_inc1"></a>
Operacje rejestrowe oraz arytmetyczno-logiczne</h2>
<p>1. Pobranie numeru rejestru i jego wartości z instrukcji: <div class="fragment"><pre class="fragment">        <span class="keywordtype">int</span> Rd_temp = (getMEMC(getPC()) &amp; 0x0FF0) &gt;&gt; 4;
        <a class="code" href="group__typy.html#ga3007400364f103d0c02f0838d05a0504" title="osmiobitowy typ danych o wartosciach od 0 do 255.">uint8_t</a> Rd = (Rd_temp &amp; 0b00011111);
        <a class="code" href="group__typy.html#ga3007400364f103d0c02f0838d05a0504" title="osmiobitowy typ danych o wartosciach od 0 do 255.">uint8_t</a> Rd_val = getRegister(Rd) % <a class="code" href="group__maxi.html#ga6125be368b2b4d2026c291477eab8c76" title="Maksymalna wartosc.">MAX_DATA_VAL</a>;
</pre></div> 2. Zwiększenie wartości o 1: <div class="fragment"><pre class="fragment">        <a class="code" href="group__typy.html#ga3007400364f103d0c02f0838d05a0504" title="osmiobitowy typ danych o wartosciach od 0 do 255.">uint8_t</a> R = Rd_val + 1;                                                                 <span class="comment">//Zwiększenie wartości o 1</span>
</pre></div> 3. Zapisanie wartosci do rejestru: <div class="fragment"><pre class="fragment">        setRegister(Rd,R);                                                                              <span class="comment">//Zapisanie wartosci do rejestru</span>
</pre></div> 4. Zwiększenie licznika rozkazów: <div class="fragment"><pre class="fragment">    incPC();                                                                                            <span class="comment">//Zwiększenie licznika rozkazów</span>
</pre></div></p>
<h2><a class="anchor" id="sec_inc2"></a>
Operacje na flagach</h2>
<p>1. Ustawienie flagi V: <div class="fragment"><pre class="fragment">        <span class="keywordflow">if</span>(Rd_val == 127) SetFlagRegisterBit(<a class="code" href="group__flagi.html#ga3ebd69b998d141f114f2b56f2a2dc939" title="Definicja flagi V.">FLAG_V</a>);                                   <span class="comment">// Ustawienie flagi V</span>
        <span class="keywordflow">else</span> ClearFlagRegisterBit(<a class="code" href="group__flagi.html#ga3ebd69b998d141f114f2b56f2a2dc939" title="Definicja flagi V.">FLAG_V</a>);
</pre></div> 2. Ustawienie flagi N <div class="fragment"><pre class="fragment">    <span class="keywordflow">if</span>( ( (Rd &amp; 0x80) &gt;&gt; 7) == 0 &amp;&amp; ((R &amp; 0x80) &gt;&gt; 7) == 1) <span class="comment">// Jeśli MSB Rd == 0 i MSB R == 1 to zmieniamy</span>
        SetFlagRegisterBit(<a class="code" href="group__flagi.html#gacdfb32bcc71b55f337986da27e992836" title="Definicja flagi N.">FLAG_N</a>);                                                                     <span class="comment">// bo nastąpiła zmiana MSB</span>
    <span class="keywordflow">else</span>
        ClearFlagRegisterBit(<a class="code" href="group__flagi.html#gacdfb32bcc71b55f337986da27e992836" title="Definicja flagi N.">FLAG_N</a>);
</pre></div> 3. Ustawienie flagi Z <div class="fragment"><pre class="fragment">    <span class="keywordflow">if</span>( R == 0 ) SetFlagRegisterBit( <a class="code" href="group__flagi.html#ga7680259bba516283fd3d3058d4858f4c" title="Definicja flagi Z.">FLAG_Z</a> );                                          <span class="comment">//Ustawienie flagi Z</span>
        <span class="keywordflow">else</span> ClearFlagRegisterBit( <a class="code" href="group__flagi.html#ga7680259bba516283fd3d3058d4858f4c" title="Definicja flagi Z.">FLAG_Z</a> );
</pre></div> 4. Ustawienie flagi S <div class="fragment"><pre class="fragment">        <span class="keywordflow">if</span>( (GetFlagRegisterStatus(<a class="code" href="group__flagi.html#gacdfb32bcc71b55f337986da27e992836" title="Definicja flagi N.">FLAG_N</a>) ^ GetFlagRegisterStatus(<a class="code" href="group__flagi.html#ga3ebd69b998d141f114f2b56f2a2dc939" title="Definicja flagi V.">FLAG_V</a>)) == 1 ){
                SetFlagRegisterBit(<a class="code" href="group__flagi.html#ga99f493db0d390efc7a4753b68c3a59d9" title="Definicja flagi S.">FLAG_S</a>);                                                             <span class="comment">//Ustawienie flagi S</span>
        }
        <span class="keywordflow">else</span> ClearFlagRegisterBit(<a class="code" href="group__flagi.html#ga99f493db0d390efc7a4753b68c3a59d9" title="Definicja flagi S.">FLAG_S</a>);
</pre></div></p>
<h2><a class="anchor" id="sec_inc3"></a>
Kod źródłowy funkcji</h2>
<div class="fragment"><pre class="fragment"><span class="comment">/*</span>
<span class="comment">================================================================================</span>
<span class="comment">        Plik: f_inc.c</span>
<span class="comment">--------------------------------------------------------------------------------</span>
<span class="comment">        Autorzy: Piotr Zdunek, Mateusz Słowikowski, Krzysztof Wiąckowski</span>
<span class="comment">        Projekt:Model mikrokontrolera AVR</span>
<span class="comment">        Kompilator: avr-gcc-4.3.5</span>
<span class="comment">        Doc: doxygen 1.7.4</span>
<span class="comment">--------------------------------------------------------------------------------</span>
<span class="comment">        Zawiera:</span>
<span class="comment">--------------------------------------------------------------------------------</span>
<span class="comment">        Komentarze:</span>
<span class="comment">================================================================================</span>
<span class="comment">*/</span>

<span class="preprocessor">#include &quot;<a class="code" href="types_8h.html" title="Biblioteka typów.">types.h</a>&quot;</span>
<span class="preprocessor">#include &quot;mem_abs.h&quot;</span>

<span class="comment">// ******************************************************************************</span>
<span class="comment">//INC - funkcja zwiększająca wartosć danego rejestru o 1</span>
<span class="comment">// ******************************************************************************</span>


<span class="keywordtype">void</span> <a class="code" href="f__inc_8c.html#ad7a4833a58a05baabae7cae1c36e8974">F_INC</a>(<span class="keywordtype">void</span>){
<span class="preprocessor">#if DEBUG_MODE</span>
<span class="preprocessor"></span>        printf(<span class="stringliteral">&quot;Function INC.&quot;</span>);
<span class="preprocessor">#endif</span>
<span class="preprocessor"></span><span class="comment">//Pobranie numeru rejestru i jego wartości z instrukcji</span>
        <span class="keywordtype">int</span> Rd_temp = (getMEMC(getPC()) &amp; 0x0FF0) &gt;&gt; 4;
        <a class="code" href="group__typy.html#ga3007400364f103d0c02f0838d05a0504" title="osmiobitowy typ danych o wartosciach od 0 do 255.">uint8_t</a> Rd = (Rd_temp &amp; 0b00011111);
        <a class="code" href="group__typy.html#ga3007400364f103d0c02f0838d05a0504" title="osmiobitowy typ danych o wartosciach od 0 do 255.">uint8_t</a> Rd_val = getRegister(Rd) % <a class="code" href="group__maxi.html#ga6125be368b2b4d2026c291477eab8c76" title="Maksymalna wartosc.">MAX_DATA_VAL</a>;
        <a class="code" href="group__typy.html#ga3007400364f103d0c02f0838d05a0504" title="osmiobitowy typ danych o wartosciach od 0 do 255.">uint8_t</a> R = Rd_val + 1;                                                                 <span class="comment">//Zwiększenie wartości o 1</span>

        setRegister(Rd,R);                                                                              <span class="comment">//Zapisanie wartosci do rejestru</span>
    incPC();                                                                                            <span class="comment">//Zwiększenie licznika rozkazów</span>

                                                                                                                        <span class="comment">// USTAWIENIE REJESTRU FLAG</span>
        <span class="keywordflow">if</span>(Rd_val == 127) SetFlagRegisterBit(<a class="code" href="group__flagi.html#ga3ebd69b998d141f114f2b56f2a2dc939" title="Definicja flagi V.">FLAG_V</a>);                                   <span class="comment">// Ustawienie flagi V</span>
        <span class="keywordflow">else</span> ClearFlagRegisterBit(<a class="code" href="group__flagi.html#ga3ebd69b998d141f114f2b56f2a2dc939" title="Definicja flagi V.">FLAG_V</a>);

    <span class="keywordflow">if</span>( ( (Rd &amp; 0x80) &gt;&gt; 7) == 0 &amp;&amp; ((R &amp; 0x80) &gt;&gt; 7) == 1) <span class="comment">// Jeśli MSB Rd == 0 i MSB R == 1 to zmieniamy</span>
        SetFlagRegisterBit(<a class="code" href="group__flagi.html#gacdfb32bcc71b55f337986da27e992836" title="Definicja flagi N.">FLAG_N</a>);                                                                     <span class="comment">// bo nastąpiła zmiana MSB</span>
    <span class="keywordflow">else</span>
        ClearFlagRegisterBit(<a class="code" href="group__flagi.html#gacdfb32bcc71b55f337986da27e992836" title="Definicja flagi N.">FLAG_N</a>);

    <span class="keywordflow">if</span>( R == 0 ) SetFlagRegisterBit( <a class="code" href="group__flagi.html#ga7680259bba516283fd3d3058d4858f4c" title="Definicja flagi Z.">FLAG_Z</a> );                                          <span class="comment">//Ustawienie flagi Z</span>
        <span class="keywordflow">else</span> ClearFlagRegisterBit( <a class="code" href="group__flagi.html#ga7680259bba516283fd3d3058d4858f4c" title="Definicja flagi Z.">FLAG_Z</a> );

        <span class="keywordflow">if</span>( (GetFlagRegisterStatus(<a class="code" href="group__flagi.html#gacdfb32bcc71b55f337986da27e992836" title="Definicja flagi N.">FLAG_N</a>) ^ GetFlagRegisterStatus(<a class="code" href="group__flagi.html#ga3ebd69b998d141f114f2b56f2a2dc939" title="Definicja flagi V.">FLAG_V</a>)) == 1 ){
                SetFlagRegisterBit(<a class="code" href="group__flagi.html#ga99f493db0d390efc7a4753b68c3a59d9" title="Definicja flagi S.">FLAG_S</a>);                                                             <span class="comment">//Ustawienie flagi S</span>
        }
        <span class="keywordflow">else</span> ClearFlagRegisterBit(<a class="code" href="group__flagi.html#ga99f493db0d390efc7a4753b68c3a59d9" title="Definicja flagi S.">FLAG_S</a>);

}
</pre></div> </div></div>
<!-- window showing the filter options -->
<div id="MSearchSelectWindow"
     onmouseover="return searchBox.OnSearchSelectShow()"
     onmouseout="return searchBox.OnSearchSelectHide()"
     onkeydown="return searchBox.OnSearchSelectKey(event)">
<a class="SelectItem" href="javascript:void(0)" onclick="searchBox.OnSelectItem(0)"><span class="SelectionMark">&#160;</span>All</a><a class="SelectItem" href="javascript:void(0)" onclick="searchBox.OnSelectItem(1)"><span class="SelectionMark">&#160;</span>Pliki</a><a class="SelectItem" href="javascript:void(0)" onclick="searchBox.OnSelectItem(2)"><span class="SelectionMark">&#160;</span>Funkcje</a><a class="SelectItem" href="javascript:void(0)" onclick="searchBox.OnSelectItem(3)"><span class="SelectionMark">&#160;</span>Definicje typów</a><a class="SelectItem" href="javascript:void(0)" onclick="searchBox.OnSelectItem(4)"><span class="SelectionMark">&#160;</span>Definicje</a></div>

<!-- iframe showing the search results (closed by default) -->
<div id="MSearchResultsWindow">
<iframe src="javascript:void(0)" frameborder="0" 
        name="MSearchResults" id="MSearchResults">
</iframe>
</div>

<hr class="footer"/><address class="footer"><small>Wygenerowano Mon Jun 6 2011 20:13:46 dla PROJEKT Z PRZEDMIOTU SYSTEMY KOMPUTEROWE (SYKO) grupa nr. 16 programem&#160;
<a href="http://www.doxygen.org/index.html">
<img class="footer" src="doxygen.png" alt="doxygen"/></a> 1.7.4 </small></address>
</body>
</html>
